package MyHttp;

import java.util.Map;

public class LoginServlet extends Servlet {
    @Override
    public String doRequest(String method, String requestUrl, String requestBody) {
        Map<String, String> params;
        if ("GET".equals(method)) {
            params = parseGetParams(requestUrl);
        } else { // POST
            params = parsePostParams(requestBody);
        }
        String username = params.getOrDefault("username", "");
        String password = params.getOrDefault("password", "");

        if ("111".equals(username) && "666".equals(password)) {
            return "<h1>登录成功</h1>";
        } else {
            return "<h1>用户名或密码错误</h1>";
        }
    }
}